require 'rubygems'

module WithString
  url = 'http://204.231.109.9/resources/compute/lamp/435'
  url_regex = "/resources"
  start_index = /#{url_regex}/ =~ url
  puts url[start_index, url.length]
end

module WithRegex
  url = 'http://204.231.109.9/resources/compute/lamp/435'
  url_regex = %r{^http://[\d+\.]+([/\w\/]+)}
  matches = url_regex.match(url)
  puts matches[1]
end